package net.zdsoft.wpchat.support.action.auth;

import javax.annotation.Resource;

import net.zdsoft.keel.util.Validators;
import net.zdsoft.wpchat.android.client.BasicAction;
import net.zdsoft.wpchat.support.service.AuthService;

/**
 * 修改密码Action
 * 
 * @author xuan
 * @version $Revision: 1.0 $, $Date: 2014-9-22 下午10:13:21 $
 */
public class ChangePasswordAction extends BasicAction {
    private static final long serialVersionUID = 4793340315690362752L;

    @Resource
    private AuthService authService;

    private String operatorId;
    private String password;
    private String verifyPassword;

    private String inputStream;

    /**
     * 跳转到修改密码页面
     * 
     * @return
     */
    public String preChangePassword() {
        return SUCCESS;
    }

    /**
     * 修改密码
     * 
     * @return
     */
    public String changePassword() {
        if (Validators.isEmpty(password)) {
            inputStream = getError("请输入密码");
            return SUCCESS;
        }
        else {
            if (!password.equals(verifyPassword)) {
                inputStream = getError("两次输入的密码不一致");
                return SUCCESS;
            }
        }

        authService.modifyPassword(operatorId, password);
        inputStream = getMessage("密码修改成功");
        return SUCCESS;
    }

    public String getOperatorId() {
        return operatorId;
    }

    public void setOperatorId(String operatorId) {
        this.operatorId = operatorId;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getVerifyPassword() {
        return verifyPassword;
    }

    public void setVerifyPassword(String verifyPassword) {
        this.verifyPassword = verifyPassword;
    }

    public String getInputStream() {
        return inputStream;
    }

    public void setInputStream(String inputStream) {
        this.inputStream = inputStream;
    }

}
